package com.game.spacetrader.map;

import java.io.Serializable;

/**
 * Class represents a pair of coordinates for a location (x,y)
 *
 */
public class Coordinates implements Comparable<Object>, Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int x, y;
	/**
	 * Constructor
	 * @param x the x value
	 * @param y the y value
	 */
	public Coordinates(int x, int y){
		this.setX(x);
		this.setY(y);
	}

	/**
	 * compares the object to an inputed object
	 * @parm arg0 the object to compare to
	 * @return 1 if greater than, 0 if equal, -1 if less
	 */
	public int compareTo(Object arg0) {
		if(arg0 instanceof Coordinates){
			if(this.x==((Coordinates) arg0).getX() && this.y==((Coordinates) arg0).getY())
				return 0;
			else if((this.x+this.y)>(((Coordinates) arg0).getX() + ((Coordinates) arg0).getY()))
				return 1;
			else
				return -1;
		}
		return 0;
	}

	/**
	 * Checks if the objects are equal
	 * @param o object to compare to
	 * @return true if equal
	 */
	public boolean equals(Object o) {
		if (this.compareTo(o)==0) {
			return true;
		}
		return false;
	}



	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}



}